﻿using System;

using Microsoft.Drawing;
using System.Drawing;

namespace Spencen.Mobile.UI.Primitives
{
    public class GradientRectangleElement : RectangleElement
    {
        public Color StartColor { get; set; }
        public Color EndColor { get; set; }
        public FillDirection FillDirection { get; set; }

        public GradientRectangleElement()
        {
            FillDirection = FillDirection.TopToBottom;
            StartColor = Color.Black;
            EndColor = Color.White;
        }

        public override bool SupportsRotation { get { return false; } }

        protected override void OnRender( GraphicsContext context )
        {
            var points = GeneratePoints();

            points = context.TransformedPoints( points ); ;

            context.Graphics.FillGradientRectangle( new Rectangle( points[ 0 ].X, points[ 0 ].Y, points[ 2 ].X - points[ 0 ].X, points[ 2 ].Y - points[ 0 ].Y ), StartColor, EndColor, FillDirection );
        }
    }
}
